package com.elitel.frame.base.controller.accessControl;

import com.elitel.frame.base.service.AcAppCatalogService;
import com.elitel.frame.main.entity.acappcatalog.AcAppCatalog;
import com.elitel.frame.main.entity.acappcatalog.AcAppCatalogDTO;
import com.elitel.frame.main.entity.acstationinfo.AcStationInfo;
import com.elitel.frame.main.entity.vo.JsonResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 访问控制-应用和测站分类(AcAppCatalog)表控制层
 *
 * @author makejava
 * @since 2023-11-11 15:15:32
 */
@RestController
@RequestMapping("accesscontrol/acAppCatalog")
public class AcAppCatalogController {

    @Resource
    private AcAppCatalogService acAppCatalogService;


    @PostMapping("save")
    public Object save(@RequestBody AcAppCatalogDTO dto) {
        JsonResult jsonResult = new JsonResult();
        jsonResult.setSuccess(true);
        acAppCatalogService.save(dto);
        return jsonResult;
    }


    @PostMapping("delCatalogByIds")
    public Object delCatalogByIds(String catalogIds) {
        JsonResult jsonResult = null;
        try {
            jsonResult = new JsonResult();
            jsonResult.setSuccess(true);
            acAppCatalogService.deleteByIds(catalogIds);
        } catch (Exception e) {
            e.printStackTrace();
            jsonResult.setSuccess(false);
            jsonResult.setMsg(e.getMessage());
        }
        return jsonResult;
    }


    @GetMapping("selectStationsById")
    public Object selectStationsById(AcAppCatalogDTO dto) {
        JsonResult jsonResult = new JsonResult();
        List<AcStationInfo> acAppCatalogDTO = acAppCatalogService.selectStations(dto);
        jsonResult.setData(acAppCatalogDTO);
        jsonResult.setSuccess(true);
        return jsonResult;
    }


    @GetMapping("selectList")
    public Object selectList(AcAppCatalogDTO dto) {
        JsonResult jsonResult = new JsonResult();
        List<AcAppCatalogDTO> acAppCatalogDTO = acAppCatalogService.selectList(dto);
        jsonResult.setData(acAppCatalogDTO);
        jsonResult.setSuccess(true);
        return jsonResult;
    }


    @GetMapping("selectListByAppIds")
    public Object selectListByAppIds(AcAppCatalogDTO dto) {
        JsonResult jsonResult = new JsonResult();
        Map<String, List<AcAppCatalogDTO>> acAppCatalogDTO = acAppCatalogService.selectListByAppIds(dto);
        jsonResult.setData(acAppCatalogDTO);
        jsonResult.setSuccess(true);
        return jsonResult;
    }


}

